Skip to content

fix: preserve Gemini thinking blocks#5713

Open
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/gemini-thinking-block-signatures
Open

fix: preserve Gemini thinking blocks#5713
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/gemini-thinking-block-signatures

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • recognize Gemini-shaped thinking_blocks even when blocks do not carry Anthropic-style per-block signatures
  • merge LiteLLM's parallel provider_specific_fields.thought_signatures into those blocks before converting them to ADK thought parts
  • add regression coverage for Gemini blocks with and without signatures, plus the generated response conversion path

Fixes #5712.

To verify

  • python -m pytest tests/unittests/models/test_litellm.py -q -k "thinking_blocks or thought_signature" --basetemp .tmp/pytest
  • python -m pytest tests/unittests/models/test_litellm.py -q --basetemp .tmp/pytest
  • python -m py_compile src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py
  • python -m pyink --check src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py

@he-yufeng he-yufeng force-pushed the fix/gemini-thinking-block-signatures branch from bee917c to 51542ce Compare May 16, 2026 09:07
@he-yufeng
Copy link
Copy Markdown
Author

Rebased this onto current upstream/main and force-pushed the branch. The PR diff is still limited to the LiteLLM Gemini thinking-block handling and its unit coverage.

Local validation after the rebase:

  • .venv\Scripts\python.exe -m pytest tests/unittests/models/test_litellm.py -q -k "thinking_blocks or thought_signature" (18 passed)
  • .venv\Scripts\python.exe -m py_compile src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py
  • .venv\Scripts\pyink.exe --check src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py
  • .venv\Scripts\isort.exe --check-only src/google/adk/models/lite_llm.py tests/unittests/models/test_litellm.py
  • git diff --check upstream/main..HEAD

The remaining visible failure is still the repository triage bot, not a code test failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[LiteLLM] _is_thinking_blocks_format drops Gemini thinking_blocks (only matches Anthropic 'signature' key)

1 participant